<!DOCTYPE html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>产品列表页</title>
    <link rel="icon" href="assets/img/favicon.ico">
    <link rel="stylesheet" type="text/css" href="css/webbase.css"/>
    <link rel="stylesheet" type="text/css" href="css/pages-list.css"/>
    <link rel="stylesheet" type="text/css"
          href="css/widget-cartPanelView.css"/>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="js/vue.js" type="application/javascript"></script>
    <script src="element-ui/lib/index.js"></script>
    <script src="js/axios.js" type="application/javascript"></script>
</head>
<body>
<div id="app" class="app">

    <!-- 头部栏位 -->
    <!--页面顶部-->
    <div id="nav-bottom">
        <!--顶部-->
        <div class="nav-top">
            <div class="top">
                <div class="py-container">
                    <div class="shortcut">
                        <ul class="fl">
                            <li class="f-item">爱思乐欢迎您！</li>
                            <li class="f-item">请 <a href="login.html" target="_blank">登录</a>
                                <span><a href="register.html" target="_blank">免费注册</a></span></li>
                        </ul>
                        <ul class="fr">
                            <li class="f-item">我的订单</li>
                            <li class="f-item space"></li>
                            <li class="f-item"><a href="home.html" target="_blank">我的爱思乐</a>
                            </li>
                            <li class="f-item space"></li>
                            <li class="f-item">爱思乐会员</li>
                            <li class="f-item space"></li>
                            <li class="f-item">企业采购</li>
                            <li class="f-item space"></li>
                            <li class="f-item">关注爱思乐</li>
                            <li class="f-item space"></li>
                            <li class="f-item" id="service"><span>客户服务</span>
                                <ul class="service">
                                    <li><a href="cooperation.html" target="_blank">合作招商</a></li>
                                    <li><a href="shoplogin.html" target="_blank">商家后台</a></li>
                                    <li><a href="cooperation.html" target="_blank">合作招商</a></li>
                                    <li><a href="#">商家后台</a></li>
                                </ul>
                            </li>
                            <li class="f-item space"></li>
                            <li class="f-item">网站导航</li>
                        </ul>
                    </div>
                </div>
            </div>

            <!--头部-->
            <div class="header">
                <div class="py-container">
                    <div class="yui3-g Logo">
                        <div class="yui3-u Left logoArea">
                            <a class="logo-bd" title="爱思乐" href="JD-index.html"
                               target="_blank"></a>
                        </div>
                        <div class="yui3-u Center searchArea">
                            <div class="search">
                                <form action="" class="sui-form form-inline">
                                    <!--searchAutoComplete-->
                                    <div class="input-append">
                                        <input type="text" id="autocomplete" type="text" v-model="searchName"
                                               class="input-error input-xxlarge"/>
                                        <button class="sui-btn btn-xlarge btn-danger" type="button" @click="SearchListByName()">
                                            搜索
                                        </button>
                                    </div>
                                </form>
                            </div>
                            <div class="hotwords">
                                <ul>
                                    <li class="f-item">爱思乐首发</li>
                                    <li class="f-item">亿元优惠</li>
                                    <li class="f-item">9.9元团购</li>
                                    <li class="f-item">每满99减30</li>
                                    <li class="f-item">亿元优惠</li>
                                    <li class="f-item">9.9元团购</li>
                                    <li class="f-item">办公用品</li>
                                </ul>
                            </div>
                        </div>
                        <div class="yui3-u Right shopArea">
                            <div class="fr shopcar">
                                <div class="show-shopcar" id="shopcar">
                                    <span class="car"></span> <a
                                        class="sui-btn btn-default btn-xlarge" href="cart.html"
                                        target="_blank"> <span>我的购物车</span> <i class="shopnum">0</i>
                                </a>
                                    <div class="clearfix shopcarlist" id="shopcarlist"
                                         style="display: none">
                                        <p>"啊哦，你的购物车还没有商品哦！"</p>
                                        <p>"啊哦，你的购物车还没有商品哦！"</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="yui3-g NavList">
                        <div class="yui3-u Left all-sort">
                            <h4>全部商品分类</h4>
                        </div>
                        <div class="yui3-u Center navArea">
                            <ul class="nav">
                                <li class="f-item">服装城</li>
                                <li class="f-item">美妆馆</li>
                                <li class="f-item">团购</li>
                                <li class="f-item">有趣</li>
                                <li class="f-item">秒杀</a></li>
                            </ul>
                        </div>
                        <div class="yui3-u Right"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--list-content-->
    <div class="main">
        <div class="py-container">
            <!--selector-->
            <div class="clearfix selector">
                <div class="type-wrap">
                    <div class="fl key">商品分类</div>
                    <div class="fl value">
                        <a href="#">手机</a> <a href="#">电视</a>
                    </div>
                    <div class="fl ext"></div>
                </div>
                <div class="type-wrap logo">
                    <div class="fl key brand">品牌</div>
                    <div class="value logos">
                        <ul class="logo-list">
                            <!--以下显示的是品牌的logo-->
                            <li><img src="img/_/phone01.png"/></li>
                            <li><img src="img/_/phone02.png"/></li>
                            <li><img src="img/_/phone03.png"/></li>
                            <li><img src="img/_/phone04.png"/></li>
                            <li><img src="img/_/phone05.png"/></li>
                            <li><img src="img/_/phone06.png"/></li>
                            <li><img src="img/_/phone07.png"/></li>
                            <li><img src="img/_/phone08.png"/></li>
                            <li><img src="img/_/phone09.png"/></li>
                            <li><img src="img/_/phone10.png"/></li>
                            <li><img src="img/_/phone11.png"/></li>
                            <li><img src="img/_/phone12.png"/></li>
                            <li><img src="img/_/phone13.png"/></li>
                            <li><img src="img/_/phone14.png"/></li>
                            <li><img src="img/_/phone05.png"/></li>
                            <li><img src="img/_/phone06.png"/></li>
                            <li><img src="img/_/phone07.png"/></li>
                            <li><img src="img/_/phone02.png"/></li>
                        </ul>
                    </div>
                    <div class="ext">
                        <a href="javascript:void(0);" class="sui-btn">多选</a> <a
                            href="javascript:void(0);">更多</a>
                    </div>
                </div>
                <div class="type-wrap">
                    <div class="fl key">网络制式</div>
                    <div class="fl value">
                        <ul class="type-list">
                            <li><a>GSM（移动/联通2G）</a></li>
                            <li><a>电信2G</a></li>
                            <li><a>电信3G</a></li>
                            <li><a>移动3G</a></li>
                            <li><a>联通3G</a></li>
                            <li><a>联通4G</a></li>
                            <li><a>电信3G</a></li>
                            <li><a>移动3G</a></li>
                            <li><a>联通3G</a></li>
                            <li><a>联通4G</a></li>
                        </ul>
                    </div>
                    <div class="fl ext"></div>
                </div>
                <div class="type-wrap">
                    <div class="fl key">显示屏尺寸</div>
                    <div class="fl value">
                        <ul class="type-list">
                            <li><a>4.0-4.9英寸</a></li>
                            <li><a>4.0-4.9英寸</a></li>
                        </ul>
                    </div>
                    <div class="fl ext"></div>
                </div>
                <div class="type-wrap">
                    <div class="fl key">摄像头像素</div>
                    <div class="fl value">
                        <ul class="type-list">
                            <li><a>1200万以上</a></li>
                            <li><a>800-1199万</a></li>
                            <li><a>1200-1599万</a></li>
                            <li><a>1600万以上</a></li>
                            <li><a>无摄像头</a></li>
                        </ul>
                    </div>
                    <div class="fl ext"></div>
                </div>
                <div class="type-wrap">
                    <div class="fl key">价格</div>
                    <div class="fl value">
                        <ul class="type-list">
                            <li><a @click="priceSearch([0,5000])">0-5000元</a></li>
                            <li><a @click="priceSearch([5000,10000])">5000-10000元</a></li>
                            <li><a @click="priceSearch([10000,20000])">10000-20000元</a></li>
                            <li><a @click="priceSearch([20000,30000])">20000-30000元</a></li>
                            <li><a @click="priceSearch([30000,60000])">30000-60000元 </a></li>
                            <li><a @click="priceSearch([60000,999999])">60000元以上</a></li>
                        </ul>
                    </div>
                    <div class="fl ext"></div>
                </div>
                <div class="type-wrap">
                    <div class="fl key">更多筛选项</div>
                    <div class="fl value">
                        <ul class="type-list">
                            <li><a>特点</a></li>
                            <li><a>系统</a></li>
                            <li><a>手机内存 </a></li>
                            <li><a>单卡双卡</a></li>
                            <li><a>其他</a></li>
                        </ul>
                    </div>
                    <div class="fl ext"></div>
                </div>
            </div>
            <!--details-->
            <div class="details">
                <div class="sui-navbar">
                    <div class="navbar-inner filter">
                        <ul class="sui-nav">
                            <!--这全部是计算的得分来分页  点击不同的地方应该是不同的分页方法-->
                            <!--点击综合带着搜索条件执行findAll-->
                            <li class="active"><a onclick="findAll()">综合</a></li>
                            <!--点击销量及其他得分方式改变  带着条件执行相关查询-->
                            <li><a @click="sales()">销量</a></li>
                            <!--<li><a @click="commentSort()">评价</a></li>-->
                            <li><a @click="priceSort()">价格</a></li>
                        </ul>
                    </div>
                </div>
                <div class="goods-list">
                    <ul class="yui3-g">
                        <li class="yui3-u-1-5" v-for="sku in skuList">
                            <div class="list-wrap">
                                <div class="p-img">
                                    <a href="item.html" target="_blank"><img
                                            :src=sku.image></a>
                                </div>
                                <div class="price">
                                    <strong> <em>¥</em> <i>{{sku.price}}</i>
                                    </strong>
                                </div>
                                <div class="attr">
                                    <em v-html=sku.name></em>
                                </div>
                                <div class="cu">
                                    <em></em>
                                </div>
                                <div class="commit">
                                    <i class="command">已有2000人评价</i>
                                </div>
                                <div class="operate">
                                    <a href="success-cart.html" target="_blank"
                                       class="sui-btn btn-bordered btn-danger">加入购物车</a> <a
                                        href="javascript:void(0);" class="sui-btn btn-bordered">对比</a>
                                    <a href="javascript:void(0);" class="sui-btn btn-bordered">关注</a>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>
                <!--elementui分页组件-->
                <div class="pagination-container">
                    <el-pagination
                            class="pagiantion"
                            @current-change="handleCurrentChange"
                            :current-page="pagination.currentPage"
                            :page-size="pagination.pageSize"
                            layout="total, prev, pager, next, jumper"
                            :total="total">
                    </el-pagination>
                </div>

            </div>

            <!--hotsale-->
            <div class="clearfix hot-sale">
                <h4 class="title">热卖商品</h4>
                <div class="hot-list">
                    <ul class="yui3-g">
                        <li class="yui3-u-1-4">
                            <div class="list-wrap">
                                <div class="p-img">
                                    <img src="img/like_01.png"/>
                                </div>
                                <div class="attr">
                                    <em>Apple苹果iPhone 6s (A1699)</em>
                                </div>
                                <div class="price">
                                    <strong> <em>¥</em> <i>4088.00</i>
                                    </strong>
                                </div>
                                <div class="commit">
                                    <i class="command">已有700人评价</i>
                                </div>
                            </div>
                        </li>
                        <li class="yui3-u-1-4">
                            <div class="list-wrap">
                                <div class="p-img">
                                    <img src="img/like_03.png"/>
                                </div>
                                <div class="attr">
                                    <em>金属A面，360°翻转，APP下单省300！</em>
                                </div>
                                <div class="price">
                                    <strong> <em>¥</em> <i>4088.00</i>
                                    </strong>
                                </div>
                                <div class="commit">
                                    <i class="command">已有700人评价</i>
                                </div>
                            </div>
                        </li>
                        <li class="yui3-u-1-4">
                            <div class="list-wrap">
                                <div class="p-img">
                                    <img src="img/like_04.png"/>
                                </div>
                                <div class="attr">
                                    <em>256SSD商务大咖，完爆职场，APP下单立减200</em>
                                </div>
                                <div class="price">
                                    <strong> <em>¥</em> <i>4068.00</i>
                                    </strong>
                                </div>
                                <div class="commit">
                                    <i class="command">已有20人评价</i>
                                </div>
                            </div>
                        </li>
                        <li class="yui3-u-1-4">
                            <div class="list-wrap">
                                <div class="p-img">
                                    <img src="img/like_02.png"/>
                                </div>
                                <div class="attr">
                                    <em>Apple苹果iPhone 6s (A1699)</em>
                                </div>
                                <div class="price">
                                    <strong> <em>¥</em> <i>4088.00</i>
                                    </strong>
                                </div>
                                <div class="commit">
                                    <i class="command">已有700人评价</i>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>


</div>
</body>

<script>
    var vue = new Vue({
        el: '#app',
        data: {
            skuList: [],
            searchName: "",
            total: 50,
            pagination: {
                //分页相关属性
                currentPage: 1,
                pageSize: 10,
                queryName: null,    //查询条件  名称
                minPrice:null,  //过滤条件    价格最小值
                maxPrice:null,  //过滤条件   价格最大值
                saleNum:2,//排序条件        :售出数量
                price:2,//排序条件         :价格
                commentNum:2//排序条件    :评论数
            },
        },
        methods: {
            SearchListByName(){
                // this.pagination.maxPrice=null;
                this.pagination.currentPage=1;
                this.pagination.queryName=this.searchName;
                console.log(this.pagination.queryName);
                this.loadData1();
            },
            loadData1() {
                console.log("Hello Vue!");
                // this.pagination.queryName=this.searchName;
                console.log(this.pagination.queryName);//搜索数据  姓名
                axios.post("/findAll",this.pagination).then((res) => {
                    // console.info("数据响应成功");
                    //数据返回值是固定的  永远都是十条数据
                    this.skuList = res.data.data.rows;
                    console.log(res.data.data.total);
                    this.total=res.data.data.total;
                    console.log(this.skuList);
                })
            },
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.loadData1();
            },
            // getData() {
            //     if (document.URL.indexOf("?") < 0) return;//获取当前url地址,如果没参数.直接返回
            //     var str = document.URL.split("?")[1];
            //     var obj = {};
            //     var arr;
            //     //当只有一个参数传过来时
            //     if (str.indexOf("&") < 0) {
            //         if (str.indexOf("=") < 0) return;
            //         arr = str.split("=");
            //         obj[arr[0]] = arr[1];
            //         return obj;
            //     }
            //     //当有多个参数时
            //     arr = str.split("&");
            //
            //     var arr1;
            //     for (var i = 0; i < arr.length; i++) {
            //         arr1 = arr[i].split("=");
            //         obj[arr1[0]] = arr1[1];
            //     }
            //     this.searchName= decodeURI( arr[2].split("=")[1]);
            // }
            //点击销量,评价数,价格排序
            sales(){
                this.pagination.currentPage=1;
                if(this.pagination.saleNum==2||this.pagination.saleNum==0){
                    //如果是2   不按照销量排序
                    this.pagination.saleNum=1;
                }else if(this.pagination.saleNum==1) {
                    //如果是1   正序排序
                    this.pagination.saleNum = 0;
                }
                console.log("这个按销量排序的标记值为"+this.pagination.saleNum);

                this.pagination.price=2;
                this.pagination.commentNum=2;
                this.loadData1();
            },
            priceSort(){
                this.pagination.currentPage=1;
                if(this.pagination.price==2||this.pagination.price==0){
                    //如果是2   不按照销量排序
                    this.pagination.price=1;
                }else if(this.pagination.price==1){
                    //如果是1   正序排序
                    this.pagination.price=0;
                }
                this.pagination.saleNum=2;
                this.pagination.commentNum=2;
                this.loadData1();
            },
            //价格排序区间排序
            priceSearch(arr){
                console.log("进入方法");
                console.log(arr);
                this.pagination.minPrice=arr[0];
                this.pagination.maxPrice=arr[1];
                this.loadData1();
            }

        },
        created() {
            // this.getData();
            this.loadData1();
        }
    });
</script>
</html>